<?php


namespace app\admin\model;


use app\common\model\News as NewModel;

class News extends NewModel
{

    public function getList($param=[])
    {
        //search,type_id
        //1.组装一个包含search,type_id新数组
        //array_merge:合并两个数组,后面的替换前面的
        $param=array_merge([
            'search'=>'',
            'type_id'=>0
        ],$param);
        //2.数组过滤
        $filters=[];
        $param['type_id']>0 && $filters['type_id']=$param['type_id'];

        return $this->where('title','like',"%{$param['search']}%")
            ->where($filters)
            ->paginate(3,false,[
                'query'=>$param
                ]);
    }
}